package com.harry.configuration.database;

import javax.persistence.EntityManagerFactory;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate5.HibernateTemplate;

/**
 * Hibernate 配置
 */
@Configuration
public class HibernateConfiguration {

	@Autowired
	EntityManagerFactory entityManagerFactory;

	@Bean
	public HibernateTemplate hibernateTemplate() {
		return new HibernateTemplate(entityManagerFactory.unwrap(SessionFactory.class));
	}
}
